Python as Calculator for Chemistry and Physics Problems
Pyhton 3
code
Jupyter Notebook
Chemistry
Physics
Author
Dinda Gusti Ayu
Published
January 7, 2025
Features
Chemistry exercises: calculations involving molar mass, wavelength, and energy.
Physics exercises: problems on mechanics, thermodynamics, and electromagnetism.
Key Equation
Einsten’s relationship between mass and energy
E = hv = \(\frac{hc}{\lambda}=mc^{2}\)
De Broglie’s relationship between mass, speed, and wavelength
\(\lambda=\frac{h}{mv}\)
Heisenberg’s uncertainty principle
\((\Delta{x})[\Delta({mv})]\geq\frac{h}{4\pi}\)
P2.1
The rate of the reaction between \(H_{2}\) and \(F_{2}\) to form HF increases by a factor of 10 when the temperature is increased from \(25 ^oC\) to \(47 ^oC\). What is the reaction activation energy? Assume the Arhenius equation applies.
# Copied from notebookimport numpy as np# The gas constant in J.K.mol-1 (4 s.f).R =8.314# Convert the second temperature from degC to K.T1, T2 =25+273, 47+273# Calculation the activation energy in J.mol-1.Ea = R * np.log(10) / (1/T1 -1/T2)print(Ea)
82979.20514937383
P2.2
Calculate the energy (in eV) of a photon with wavelength of 450 nm. One eV is equivalent to \(1.6\) x \(10^{-19}\) Joules.
# Copied from notebook# Planck's constant, in J.s.h =6.626*10**-34# Constant J_per_eVJ_per_eV =1.6*10**-19# Convert wavelengths nm to m.Lambda =450*10**-9# Speed of light, in m.s-1.c =3.0*10**8# Calculate energy of photon in J.Energy_J = h * c / LambdaEnergy_J
4.417333333333333e-19
P2.3
From back-scattering experimental data, the radius of an aluminum nucleus can be calculated to be approximately 5 x 10 meters. The radius of an aluminum atom is known to be 1.43 x 10 meters. Using atomic weight data from your periodic table, calculate the density of an aluminum nucleus. Express your answer in units of g/m.
# Constant radius of alumunium nucleus R =5*10**-15# The mass of alumunium, in amum_amu =26.98# Constant atomic mass units to kg.m_kg =1.66*10**-27# Convert mass of alumunium from amu to kg.m = m_amu * m_kg# Calculate the volume of the alumunium nucleaus, in m3V =4/3*3.14* (R **3)# Calculate the density of the alumunium nucleus, in g.m-1.Rho = m / Vprint(f'{m:.3e}, {V:.3e}, {Rho:.3e}')
4.479e-26, 5.233e-43, 8.558e+16
P2.4
Body fat (triglyceride) has the average chemical formula \(C_{55}H_{104}O_{6}\). In the absence of other mechanism (such as ketosis), its metaboilsm is essentially a low temperature combustion to form carbon dioxide and water.
Calculate the mass of \(CO_{2}\) and \(H_{2}O\) produced when 1 kg of fat is “burned off”. Take the molar masses to be M(C) = 12 g \(mol^{-1}\) and M (H) = 1 g \(mol^{-1}\) and M(O) = 16 g \(mol^{-1}\). What percentage of the original mass of fat is exhaled as \(CO_{2}\)?.
The balanced chemical reaction for the metabolism of the fat \(C_{55}H_{104}O_{6}\) is:
# The molar masses of C, H and O, in g.mol-1.M_C =12M_H =1M_O =16# Calculate molar masses of fatt, CO2 and H2O, in g.mol-1M_fat = (55* M_C) + (104* M_H) + (6* M_O)M_CO2 = (1* M_C) + (2* M_O)M_H2O = (2* M_H) + (1* M_O)# Calculate ratio mass ratios (stoichiometry), in g.M_fat_per_mole =1* M_fatM_CO2_per_mole =55* M_CO2M_H2O_per_mole =52* M_H2O# Calculate mass CO2 and H2O from 1000 g of fat, in g.M_CO2_fat =1000* (M_CO2_per_mole / M_fat_per_mole)M_H2O_fat =1000* (M_H2O_per_mole / M_fat_per_mole)# Calculate percentage of original mass exhaled CO2 and H2O, in %.Percen_CO2 = ((55* M_C +2/3*6* M_O) / M_fat) *100Percen_H2O = ((104* M_H +1/3*6* M_O) / M_fat) *100print(f'{M_CO2_fat:.2f}, {M_H2O_fat:.2f}, {Percen_CO2:.3f}, {Percen_H2O:.3f}')
2813.95, 1088.37, 84.186, 15.814
P2.5
What is the boiling point of water on the summit of Mt Everest (8,849 m)?. Assume that the ambient air pressure, p, decrease with altitude, z, according to p = p0 exp(-z/H), Where p0 = 1 atm and take scale height, H to be 8 km. The molar entalpy of vaporization of water is
# Constant the normal boiling point of water T1 at p 1 atm, in K.T1 =100+273# The moalr entalphy of vaporization, in J.mol-1.Delta_H_vap =44*1000# The ideal gas constant, in J.mol-1.K-1.R =8.314# Height of Everest, in m.z =8849# The height scale, in m.H =8*1000import numpy as np# Calculate pressure with p0 = 1 atm, in atm.P1 =1P2 = P1 * np.exp(-z / H)# Calculate Boiling point use the Clausius-Clapeyron, in K.Boil_per_T2= (1/ T1) - ((R / Delta_H_vap) * np.log(P2 / P1))P2, Boil_per_T2# Calculate T2, in K and convet to degC.Boil_T2 = (1/ (Boil_per_T2)) -273Boil_T2
np.float64(73.02405457523281)
P2.6
Calculate the ionization energy (in eV) of an electron in the excited state of n = 3 in a hydrogen atom.
# Rydberg's constant, in m-1.R =1.097*10**7# Planck's constant, in J.sh =6.626*10**-34# Speed of light, in m.s-1c =3.0*10**8# Constant J_per_eVJ_per_eV =1.6*10**-19# The number or orbitn =3# Calculate energy of an electron in a particular orbit n = 3, in eV.En =-(R * h * c) / (n **2)En_eV = En / J_per_eV# Energy final, in infiniteE_final =0# Calculate the ionization energyDelta_E = E_final - En_eVDelta_E
1.5143170833333335
P2.7
The pfund series of lines in the emission spectrum of hydrogen correspond to transition from higher excited states to the n = 5 orbit. Calculate the wavelength of the second line in the Pfund series to three significant figures. In which region of the spectrum does it lie?
# Rydberg's constant, in m-1.R =1.097*10**7# Orbit at the second state and initial state, in orbit.n2 =7**2n1 =5**2# Calculate the wavelength use the Rydberg equation, in nm.Lambda_m =1/ (R * ((1/ n1) - (1/n2)))Lambda_nm = Lambda_m *10**9Lambda_nm
4652.841081738073
P2.8
Determine the wavelength of radiation (in nm) emitted by a transition from n=5 to n=3 in atomic hydrogen.
# Rydberg's constant, in m-1.R =1.097*10**7# Orbit at the second state and initial state, in orbit.n2 =5**2n1 =3**2# Calculate the wavelength of radiation, in nm.lambda_m =1/ (R * ((1/n1) - (1/n2)))lambda_nm = lambda_m *10**9print(f'{lambda_nm:.2f}')
1281.91
P2.9
Calculate the wavelenght of neutron that is moving at 3.00 x \(10^{3}\) m/s.
# the speed moving of neutron, in m/s.v =3.00*10**3# Planck's constant, in J.sh =6.626*10**-34# Mass of neutron, in kg.m =1.674929*10**-27# Calculate the wavelength of neutron, in Angstrong.Lambda_m = h / (m * v)Lambda_A = Lambda_m *10**10Lambda_pm = Lambda_m *10**12print(f'{Lambda_A:.3f}, {Lambda_pm:.3f}')
1.319, 131.866
P2.10
Calculate the minimum uncertainty in the position of an electron traveling at one-third the speed of light, if the uncertainty in its speed $$0.1%. Assumes its mass to be equal to its mass at rest.
# Planck's constant, in J.sh =6.626*10**-34# the speed of light, m/sc =3.0*10**8# Mass of electron, in kg.m =9.109390*10**-31# Calculate the uncertainty electron's velocity, in m/cv = c /3# the electron's velocity is one-third the speed lightdelta_v = (0.1/100) * v # the uncertainty speed is 0.1%#calculate the uncertainty by Heisenberg equation, in mdelta_x = (h/ (4*3.1416)) * (1/(m*delta_v))print(f'{delta_x:.3e}')